<%@ page import="ghr.day0109.travelt.dao.RelationDao" %>
<%@ page import="ghr.day0109.travelt.dao.impl.RelationDaoImpl" %>
<%@ page import="ghr.day0109.travelt.dao.ScenicDao" %>
<%@ page import="ghr.day0109.travelt.dao.impl.ScenicDaoImpl" %>
<%@ page import="java.util.List" %>
<%@ page import="ghr.day0109.travelt.entity.TourScenicRelation" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="ghr.day0109.travelt.entity.ScenicSpot" %><%--
  Created by IntelliJ IDEA.
  User: Gong
  Date: 2023/1/9
  Time: 20:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    RelationDao relationDao = new RelationDaoImpl();
    ScenicDao scenicDao = new ScenicDaoImpl();
    List ssId = new ArrayList();
    String id = request.getParameter("id");
    List<TourScenicRelation> relations = relationDao.queryOneRelation(id);
    for (int i = 0; i <relations.size() ; i++) {
        ssId.add(relations.get(i).getSsId());
    }
    String ssId1= StringUtils.strip(ssId.toString(), "[]");
    String[] str = ssId1.split(",");
    List<ScenicSpot> spots = new ArrayList<>();
    List<ScenicSpot> spots1 = new ArrayList<>();

    for (int i = 0; i <str.length ; i++) {
        spots = scenicDao.queryOneScenic(str[i]);
        spots1.add(spots.get(0));
    }
    session.setAttribute("index",spots1);

   //request.getRequestDispatcher("/ab").forward(request,response);
   response.sendRedirect("http://localhost:8080/java_web_2023_01_09/ab");
%>
<h2></h2>
</body>
</html>
